package org.ladybug.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

public class HomeController extends AbstractController {

	private String context = null;
	@Override
	protected ModelAndView handleRequestInternal(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		System.out.println("HomeController.handleRequestInternal()");
		String uri = request.getRequestURI();
		String context = getContext();
		uri = uri.substring(uri.indexOf(context)+1);
		System.out.println(uri);
		uri = uri.substring(uri.lastIndexOf("/")+1);
		System.out.println(uri);
		uri=uri.substring(0,uri.lastIndexOf("."));
		System.out.println("------------------------> "+uri);
		ModelAndView model = new ModelAndView(uri);
		
		return model;
	}
	public String getContext() {
		return context;
	}
	public void setContext(String context) {
		this.context = context;
	}


}
